From 0080d0410305fdd6e4d4516b4c229693690df670 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:31:08 -0600 Subject: [PATCH] use a signed type for waypt_counts and route counts. (#1307) * use a signed type for waypt_counts and route counts. Although larger in Qt6, the underlying type is signed. * fix -Wformat-signedness warnings introduced by this PR. * fix new -Wsign-conversion warnings. --- defs.h | 10 +++++----- kml.cc | 2 +- kml.h | 2 +- route.cc | 8 ++++---- tpg.h | 2 +- validate.cc | 20 ++++++++++---------- validate.h | 6 +++--- waypt.cc | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/defs.h b/defs.h index 93f2b5d0b..ae382c924 100644 --- a/defs.h +++ b/defs.h @@ -490,7 +490,7 @@ void waypt_init(); void waypt_add(Waypoint* wpt); void waypt_del(Waypoint* wpt); void del_marked_wpts(); -unsigned int waypt_count(); +int waypt_count(); void waypt_status_disp(int total_ct, int myct); //void waypt_disp_all(waypt_cb); /* template */ //void waypt_disp_session(const session_t* se, waypt_cb cb); /* template */ @@ -674,10 +674,10 @@ private: }; void route_init(); -unsigned int route_waypt_count(); -unsigned int route_count(); -unsigned int track_waypt_count(); -unsigned int track_count(); +int route_waypt_count(); +int route_count(); +int track_waypt_count(); +int track_count(); route_head* route_head_alloc(); void route_add_head(route_head* rte); void route_del_head(route_head* rte); diff --git a/kml.cc b/kml.cc index db5bfbd75..cacf0385c 100644 --- a/kml.cc +++ b/kml.cc @@ -90,7 +90,7 @@ const QVector KmlFormat::mt_fields_def = { { wp_field::sat, "satellites", "Satellites", "int" }, }; -void KmlFormat::kml_init_color_sequencer(unsigned int steps_per_rev) +void KmlFormat::kml_init_color_sequencer(int steps_per_rev) { if (rotate_colors) { float color_step = strtod(opt_rotate_colors, nullptr); diff --git a/kml.h b/kml.h index eef489c57..4ed4d4008 100644 --- a/kml.h +++ b/kml.h @@ -132,7 +132,7 @@ private: /* Member Functions */ - void kml_init_color_sequencer(unsigned int steps_per_rev); + void kml_init_color_sequencer(int steps_per_rev); static constexpr int kml_bgr_to_color(int blue, int green, int red) { return (blue)<<16 | (green)<<8 | (red); diff --git a/route.cc b/route.cc index a065bd5fb..c4c25f56e 100644 --- a/route.cc +++ b/route.cc @@ -46,27 +46,27 @@ route_init() global_track_list = new RouteList; } -unsigned int +int route_waypt_count() { /* total waypoint count -- all routes */ return global_route_list->waypt_count(); } -unsigned int +int route_count() { return global_route_list->count(); /* total # of routes */ } -unsigned int +int track_waypt_count() { /* total waypoint count -- all tracks */ return global_track_list->waypt_count(); } -unsigned int +int track_count() { return global_track_list->count(); /* total # of tracks */ diff --git a/tpg.h b/tpg.h index 6f4b098d3..0fa129b3b 100644 --- a/tpg.h +++ b/tpg.h @@ -75,7 +75,7 @@ private: char* tpg_datum_opt{}; int tpg_datum_idx{}; - unsigned int waypt_out_count{}; + int waypt_out_count{}; QVector tpg_args = { {"datum", &tpg_datum_opt, "Datum (default=NAD27)", "N. America 1927 mean", ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, diff --git a/validate.cc b/validate.cc index 23cf30b81..f3d20d664 100644 --- a/validate.cc +++ b/validate.cc @@ -64,10 +64,10 @@ void ValidateFilter::process() } waypt_disp_all(validate_point_f); if (debug) { - fprintf(stderr, "point ct: %u, waypt_count: %u\n", point_ct, waypt_count()); + fprintf(stderr, "point ct: %d, waypt_count: %d\n", point_ct, waypt_count()); } if (!debug && (point_ct != waypt_count())) { - fatal(MYNAME ":Waypoint count mismatch, expected %u, actual %u\n", waypt_count(), point_ct); + fatal(MYNAME ":Waypoint count mismatch, expected %d, actual %d\n", waypt_count(), point_ct); } head_ct = 0; @@ -78,14 +78,14 @@ void ValidateFilter::process() } route_disp_all(validate_head_f, validate_head_trl_f, validate_point_f); if (debug) { - fprintf(stderr, "route head ct: %u, route_count: %u\n", head_ct, route_count()); - fprintf(stderr, "total route point ct: %u, route_waypt_count: %u\n", point_ct, route_waypt_count()); + fprintf(stderr, "route head ct: %d, route_count: %d\n", head_ct, route_count()); + fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", point_ct, route_waypt_count()); } if (!debug && (head_ct != route_count())) { - fatal(MYNAME ":Route count mismatch, expected %u, actual %u\n", route_count(), head_ct); + fatal(MYNAME ":Route count mismatch, expected %d, actual %d\n", route_count(), head_ct); } if (!debug && (point_ct != route_waypt_count())) { - fatal(MYNAME ":Total route waypoint count mismatch, expected %u, actual %u\n", route_waypt_count(), point_ct); + fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), point_ct); } head_ct = 0; @@ -96,14 +96,14 @@ void ValidateFilter::process() } track_disp_all(validate_head_f, validate_head_trl_f, validate_point_f); if (debug) { - fprintf(stderr, "track head ct: %u, track_count: %u\n", head_ct, track_count()); - fprintf(stderr, "total track point ct: %u, track_waypt_count: %u\n", point_ct, track_waypt_count()); + fprintf(stderr, "track head ct: %d, track_count: %d\n", head_ct, track_count()); + fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", point_ct, track_waypt_count()); } if (!debug && (head_ct != track_count())) { - fatal(MYNAME ":Track count mismatch, expected %u, actual %u\n", track_count(), head_ct); + fatal(MYNAME ":Track count mismatch, expected %d, actual %d\n", track_count(), head_ct); } if (!debug && (point_ct != track_waypt_count())) { - fatal(MYNAME ":Total track waypoint count mismatch, expected %u, actual %u\n", track_waypt_count(), point_ct); + fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), point_ct); } if (checkempty) { diff --git a/validate.h b/validate.h index eff779d5c..7a91388dc 100644 --- a/validate.h +++ b/validate.h @@ -44,9 +44,9 @@ private: bool debug{}; char* opt_checkempty{}; bool checkempty{}; - unsigned int point_ct{}; - unsigned int head_ct{}; - unsigned int segment_ct_start{}; + int point_ct{}; + int head_ct{}; + int segment_ct_start{}; const char* segment_type{}; QVector args = { { diff --git a/waypt.cc b/waypt.cc index f7f0783b8..e7c8c1898 100644 --- a/waypt.cc +++ b/waypt.cc @@ -73,7 +73,7 @@ del_marked_wpts() global_waypoint_list->del_marked_wpts(); } -unsigned int +int waypt_count() { return global_waypoint_list->count(); -- 2.30.2